package io.mvvm.ws;

import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @program: Netty
 * @description: Netty 启动器
 * @author: 潘
 * @create: 2021-04-21 19:25
 **/
@Component
public class NettyServerStarter implements CommandLineRunner {

    @Resource
    private NettyServer nettyServer;

    @Override
    public void run(String... args) throws Exception {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    nettyServer.start();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        thread.setName("Netty-Server");
        thread.start();
    }
}
